<script setup lang="ts">
import appStore from '@/store/modules/app'

const route = useRoute()
const router = useRouter()
const useAppStore = appStore()

const headerRoutes = ref([
  {
    name: '首页',
    key: 'index',
  },
  {
    name: '公司介绍',
    key: 'company',
  },
  {
    name: '行业案例',
    key: 'case',
  },
  {
    name: '产品中心',
    key: 'products',
  },
  {
    name: '服务中心',
    key: 'service',
  },
  {
    name: '合作客户',
    key: 'customer',
  },
  {
    name: '商务合作',
    key: 'business',
  },
])

function handleJump(to: any) {
  useAppStore.setFloor(to, route, router)
}
</script>

<template>
  <header class="header-container">
    <div class="header-wrapper">
      <!-- logo -->
      <RouterLink to="/">
        <img src="http://placehold.it/200x55/5333ed/fff">
      </RouterLink>
      <!-- menu -->
      <div class="header-menu">
        <div v-for="(item, index) in headerRoutes" :key="index" class="header-menu--item" :class="{ 'is-active': item.key === useAppStore.currentFloor }" @click="handleJump(item.key)">
          {{ item.name }}
        </div>
      </div>
    </div>
  </header>
</template>

<style lang="scss" scoped>
.header-container {
  display: flex;
  justify-content: center;
  width: 100%;
  height: $g-header-heigth;
}

.header-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: $g-app-width;
}

.header-menu {
  display: flex;

  &--item {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 25px;
    font-size: 16px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.1s;

    &.is-active {
      font-weight: 900;
      color: var(--el-color-primary);
    }

    &:hover {
      color: #fff;
      background-color: var(--el-color-primary);
    }
  }
}
</style>
